﻿namespace Controllers
{
    using System;
    using System.Diagnostics;

    /// <summary>
    /// Controller for merged file loading
    /// </summary>
    public static class LoadMergedFile
    {
        /// <summary>
        /// Method for load merged file to WebBrowser
        /// </summary>
        public static void LoadFile()
        {
            string path = Process.GetCurrentProcess().MainModule.FileName;
            string[] splitingpath = path.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries);
            path = default(string);
            for (int i = splitingpath.Length - 5; i > -1; i--)
            {
                path = splitingpath[i] + '\\' + path;
            }

            string leftfile = path + "FilesExamples\\Customer\\1.xml";
            string rightfile = path + "FilesExamples\\930SP5\\1.xml";
            string ancestorfile = path + "FilesExamples\\920SP6\\1.xml";
            string mergefile = path + "FilesExamples\\Merge\\1.xml";

            ScriptsExecution.ExecMergeScript(path, leftfile, rightfile, ancestorfile, mergefile);

            MergedFile = mergefile;
        }

        /// <summary>
        /// The hole path of file which will present in near WebBrowser Window
        /// It's a merged file from all 3 versions
        /// </summary>
        public static string MergedFile { get; set; }
    }
}
